Accessing global variables in a flash[:notice]
Posted
by Trip
on Stack Overflow
See other posts from Stack Overflow
or by Trip
Published on 2010-05-12T13:06:13Z
Indexed on
2010/05/12
13:54 UTC
Read the original article
Hit count: 130
ruby-on-rails
|ruby
This is deals_controller.rb. And it works like this, except two things.
- Not sure how to call Deal.count to add in my flash[:notice] . I get the hunch that its not calling something global.
I need that contional statement back, as I'm pretty sure its responsible for actually adding the new @deal . So I assume my syntax is off. Do note, I added an extra 'end' when I uncomment this block.
def create
-# This will use the disclaimer_ids submitted from the check boxes in the view
-# to add/delete deal.disclaimers entries to matched the list of checked boxes.
@deal = Deal.new(params[:deal])
-# <------I Need this commented out IF statement back ------->
-#if @deal.valid? && @organization.deals << @deal
flash[:notice] = 'Your promotion is published! You may find it in the number 1 position of our #{deal.count} previously posted promotions. To see your promotion, click here."'
respond_to do |format|
format.html { redirect_to organization_deals_path(@organization) }
format.js
-# I Need this IF Statement Back!
-#else
-#@disclaimers = Disclaimer.all
-#render :action => 'new' end end
Thanks!
© Stack Overflow or respective owner